package com.tshopping.dao;

import com.tshopping.bean.StoreCollection;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
public interface StoreCollectionDao {

    @Insert("insert into store_collection(user,store,time) values(#{user},#{store},#{time})")
    boolean insertStoreCollection(@Param("user") int user, @Param("store") int store, @Param("time") String time);

    @Delete("delete from store_collection where id=#{id}")
    boolean deleteStoreCollectionById(@Param("id") int id);

    @Select("select * from store_collection where user = #{user} limit #{start},#{size}")
    ArrayList<StoreCollection> selectStoreCollectionsByUserId(@Param("user") int user, @Param("start") int start, @Param("size") int size);

    @Select("select count(*) from store_collection where store=#{store} and user=#{user}")
    int selectCountByStoreAndUser(@Param("store") int store, @Param("user") int user);

    @Select("select count(*) from store_collection where user =#{user}")
    int selectCountByUserId(@Param("user") int user);

    @Delete("delete from store_collection where user=#{user} and store=#{store}")
    boolean deleteStoreCollectionByUserAndStore(@Param("user")int user,@Param("store")int store);
}
